<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const obj = {
      name: 'zp',
      age: 18,
      family: {
        son: 'lwj'
      }
    }
    // 方法一：
    // const newObj = {}
    // Object.assign(newObj, obj)
    // 方法二：
    const newObj = { ...obj }
    newObj.name = 'lzt'
    newObj.family.son = 'lzt'
    console.log(newObj)
    console.log(obj)
  </script>
</body>

</html>